#include "NormalGuide.h"
#include "VisibleRect.h"
#include "Resources.h"
#include "NormalMenu.h"
#include "GameLayer.h"
#include "LevelManager.h"


bool NormalGuide::init()
{
	bool bRet = false;
	do 
	{
		CC_BREAK_IF(!BaseLayer::init());
		addBg(1);
		CCTexture2D *pT = CCTextureCache::sharedTextureCache()->textureForKey(s_screens5);
		CCSprite *pGuide = CCSprite::createWithTexture(pT, CCRectMake(150, 430, 260, 290));
		CCSize screenSize = CCEGLView::sharedOpenGLView()->getFrameSize();
		float scale = screenSize.height / pGuide->getContentSize().height;
		pGuide->setScale(1.5);
		pGuide->setPosition(ccpAdd(VisibleRect::center(), ccp(0, 60)));
		this->addChild(pGuide);

		CCRect rect = CCRectMake(230, 310, 90, 90);
		CCSprite *pN1 = CCSprite::createWithTexture(pT, rect);
		CCSprite *pS1 = CCSprite::createWithTexture(pT, rect);
		CCSprite *pD1 = CCSprite::createWithTexture(pT, rect);
		CCMenuItemSprite *pItem = CCMenuItemSprite::create(pN1, pS1, pD1, this, menu_selector(NormalGuide::onPlay));
		pItem->setPosition(ccpAdd(VisibleRect::bottom(), ccp(0, 90)));
		pItem->setScale(1.5f);
		CCMenu *pMenu = CCMenu::create(pItem, NULL);
		pMenu->setPosition(CCPointZero);
		this->addChild(pMenu);
		bRet = true;
	} while (0);
	return bRet;
}
void NormalGuide::keyBackClicked()
{
	CCTransitionFade *pScene = CCTransitionFade::create(0.5f, NormalMenu::scene());
	CCDirector::sharedDirector()->replaceScene(pScene);
}
void NormalGuide::onPlay(CCObject *pSender)
{
	//gLevelManager->reset();
	CCTransitionFade *pScene = CCTransitionFade::create(0.5f, GameLayer::scene());
	CCDirector::sharedDirector()->replaceScene(pScene);
}